// 云调用~生成小程序二维码
const cloud = require('wx-server-sdk');

cloud.init();

exports.main = async (event, context) => {
  var scene = event.scene;
  var page = event.page || ''; //为空则是首页
  var width = event.width;

  try {
    // 1、通过云调用生成二维码
    const result = await cloud.openapi.wxacode.getUnlimited({
      scene,
      page,
      width,
      isHyaline: true
    })

    return result;

  } catch (err) {
    return err;
  }
}
